package hcs.core.domain.utils;

import org.springframework.core.env.Environment;

/**
 * @author draper_hxy
 */
public class SpringProfileUtil {

    public static String getProfileFromEnvironment(Environment environment) {
        String[] profiles = environment.getActiveProfiles();
        if (profiles != null && profiles.length != 0) {
            return profiles[0];
        }
        profiles = environment.getDefaultProfiles();
        if (profiles != null && profiles.length != 0) {
            return profiles[0];
        }
        throw new IllegalStateException("Must specify a spring profile in the environment");
    }

}
